package com.sqm.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 功能: JWT拦截器
 * 作者: 沙琪马
 * 日期: 2024/5/21 18:40
 */
@Configuration
public class WebSocketConfiguration extends WebMvcConfigurationSupport {
    @Override
    protected void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(jwtInterceptor()) // 配置Jwt的拦截器规则
                .addPathPatterns("/**")  // 拦截所有的请求路径
                .excludePathPatterns("/login","/register")
                .excludePathPatterns("/items/**");
        super.addInterceptors(registry);
    }

    @Bean
    public JwtInterceptor jwtInterceptor() {
        return new JwtInterceptor();
    }

}
